package cn.com.bluemoon.daps.sync.core.sync.compare;

import cn.com.bluemoon.daps.common.toolkit.BmAssetUtils;
import cn.com.bluemoon.daps.model.entity.DapDataModelSubordinateKey;
import cn.com.bluemoon.daps.model.entity.DapDataModelTable;
import cn.com.bluemoon.daps.sync.core.sync.GlobalConfig;
import cn.com.bluemoon.daps.sync.core.sync.Tuple2;

import java.util.List;


/**
 * 索引数据对比
 * 利用bmSql进行生成sql后采集返回
 *
 * @author Jarod.Kong
 * @date 2021/1/14 9:55
 */
public abstract class IndexComparator<R> extends BaseComparator<DapDataModelSubordinateKey, R> {

    public IndexComparator(GlobalConfig globalConfig, Tuple2<DapDataModelTable> tableTuple2) {
        super(globalConfig, tableTuple2);
    }

    @Override
    public void change0(List<R> collector) {
        BmAssetUtils.notNull(oldTable, "索引语句-表信息不可为空");
        BmAssetUtils.notNull(newTable, "索引语句-表信息不可为空");
        BmAssetUtils.notNull(getOldT(), "索引语句-旧索引信息不可为空");
        BmAssetUtils.notNull(getNewT(), "索引语句-新索引信息不可为空");
    }

    @Override
    public void drop0(List<R> collector) {
        BmAssetUtils.notNull(oldTable, "索引语句-表信息不可为空");
        BmAssetUtils.notNull(getOldT(), "索引语句-旧索引信息不可为空");
    }

    @Override
    public void create0(List<R> collector) {
        BmAssetUtils.notNull(newTable, "索引语句-表信息不可为空");
        BmAssetUtils.notNull(getNewT(), "索引语句-新索引信息不可为空");
    }
}
